home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 732 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. From: tottinge@csci.csc.com (Tim Ottinger)
  2. Message-ID: <4ibvn8$4gr@venus.roc.csci.csc.com>
  3. X-Original-Date: Fri, 15 Mar 96 13:48:15 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 15 Mar 96 15:06:25 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: istrstreams and width
  9. Organization: CSC CIS - TRIS DIVISION
  10. X-Newsreader: News Xpress Version 1.0 Beta #3
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMUmHjOEDnX0m9pzZAQFitgF+KjIHWV8r6/PxMUsHHkPOTNJHLf7OdUyZ
  13.     Gj7zBxNWNZ++zQmjyoNBZvdK2TgTx2nu
  14.     =HTMK
  15.  
  16. We've already worked around this (identified two way to do so) but we 
  17. wonder why it doesn't work this way:
  18.  
  19. Given:
  20.     istrstream source;
  21.     int i;
  22.     string s;
  23.     source >> setw(2) >> i >> s;
  24.  
  25. With fixed length fields (yes, we have to read mainframe data from time to 
  26. time, and a few other odd sources), sometimes the fields are butted up against
  27. each other, and sometimes the strings have initial digit characters i them.
  28.  
  29. When the stream contains "01115 N Neil", it would be nice if "01" and "115 N 
  30. Neil" were broken out, but every compiler we try pulls "01115" as the number, 
  31. and "N Neil" is the string.
  32.  
  33. Of course, if we insert whitespace or use read, this works.  And we should use
  34. read() because we're doing fixed length, but I was wondering why setw() 
  35. doesn't apply to integer extractors.
  36.  
  37. Surely a lot of people have to read fixed-length records, and this is a common
  38. thing.
  39.  
  40. Any thoughts?
  41. Tim
  42.  
  43. ******************************************************************************
  44. * Tim Ottinger, Sr Tech                       tottinge@csci.csc.com *
  45. * CSC Communications Industry Services                   217-351-8508x2420 *
  46. * TRIS Division -- Cellular Billing and Support                Fax 217-351-2640 *
  47. ******************************************************************************
  48. * Requirements have always been the least stable part of any project I have  *
  49. * worked upon.                            -- Robert Martin via Usenet 12/02/95 *
  50. ******************************************************************************
  51. ---
  52. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  53. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  54. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  55. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  56. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  57.